class Follower < ActiveRecord::Base
  
  # To avoid complexity, use raw SQL. Only works for MySQL.
  # Quick and Dirty way to solve the problem.
  
  def self.friend_count(id)
    friends = Follower.find_by_sql("SELECT * FROM followers WHERE follower_id='#{id}'")
    return friends.size
  end
  
  def self.follower_count(id)
    friends = Follower.find_by_sql("SELECT * FROM followers WHERE user_id='#{id}'")
    return friends.size
  end
  
  def self.get_friend_list(id)
    Follower.find_by_sql("SELECT * FROM followers WHERE follower_id='#{id}'")
  end
  
  def self.get_follower_list(id)
    Follower.find_by_sql("SELECT * FROM followers WHERE user_id='#{id}'")
  end
  
end
